﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CodeSample.Model
{
    public class SampleDescription : IEquatable<SampleDescription>
    {
        private string author;
        private string purpose;
        private string details;

        public string Details
        {
            get { return details; }
            set { details = value; }
        }

        public string Purpose
        {
            get { return purpose; }
            set { purpose = value; }
        }

        public string Author
        {
            get { return author; }
            set { author = value; }
        }

        public SampleDescription(string author,
            string purpose, string details)
        {
            this.author = author;
            this.purpose = purpose;
            this.details = details;
        }

        public override string ToString()
        {
            return string.Format(
                ">>What Code Do:\n{0}\n\n" +
                (this.details.Trim() == "" ? "" :
                ">>More Details:\n{1}\n\n") +
                ">>Author:\n{2}",
                this.purpose, this.details, this.author);
        }

        public bool Equals(SampleDescription other)
        {
            if (!this.author.Trim().ToUpper().Equals(other.author.Trim().ToUpper()))
                return false;

            if (!this.purpose.Trim().ToUpper().Equals(other.purpose.Trim().ToUpper()))
                return false;

            if (!this.details.Trim().ToUpper().Equals(other.details.Trim().ToUpper()))
                return false;

            return true;
        }
    }
}
